package java;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
@WebServlet("/Response")
public class MyServlet extends HttpServlet {
    public MyServlet()
    {
        super();
    }
    public void doGet(HttpServletRequest request,HttpServletResponse response)
            throws ServletException,IOException
    {
        doPost(request,response);
    }
    public void doPost(HttpServletRequest request,HttpServletResponse response)
            throws ServletException,IOException
    {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out=response.getWriter();
        out.println("客户端提交的方法："+request.getMethod());
        out.println("传输协议为："+request.getProtocol());
        out.println("当前ip为："+request.getRemoteAddr());
        out.println("当前服务器名称为："+request.getServerName());
        out.flush();
        out.close();
    }
}
